import random
from multiprocessing import Process

result=[]
def compute():
    '''计算100万个1到100之间的随机数的和'''
    total = sum([random.randint(1,100) for i in range(1000000)])
    result.append(total)

def main():
    processes = [Process(target=compute) for _ in range(8)]
    for process in processes:
        process.start()
    for process in processes:
        process.join()
    # 每个进程有自己独立的内存空间，进程间不共享内存
    # 如果要共享的话，要做多进程通信
    print(result)

if __name__ == '__main__':
    main()